In a computer system, a container can function as a lightweight virtual machine. That is, the container is a type of virtualization of a resource on an operating system layer and is used to isolate processes and resources. With assistance of the container, the operating system of the computer system can enable an application program to run as if on an independent machine. The operating system effectively partitions the resources managed by a single operating system to an isolated group to better balance conflicted resource use requirements between isolated groups. Common container technologies include Solaris Zones, BSD Jails, and containers in a Linux operating system.
In a Linux kernel, generally, a control group file system may be used to manage the container. The control group is used to perform control on behaviors of a group of processes, thereby limiting system resources used by processes and sub-processes thereof. Accordingly, before the container is used, the control group file system needs to be mounted. For example, a control group directory “/cgroup” is created, and a control group file is generated in the directory to limit the system resources used by the processes.
During a running process of the container, a container state and a process state may need to be backed up/restored (checkpoint/restart, C/R), which requires that a state (for example, a resource limit state of the container) of the control group at a moment be learnt. In a common solution, all control group files in the control group directory are traversed to acquire and save the state of the control group. Generally, tens of control group files are saved in the control group directory “/cgroup”. Therefore, system overhead of a traversing mechanism is larger, and the system overhead linearly grows with an increase of the number of files.